from typing import List


class Solution:
    def avoidFlood(self, rains: List[int]) -> List[int]:
        n = len(rains)
        rain_records = set()
        zero = []
        ans = [-1] * n
        for i in range(n):
            if rains[i]:
                t = rains[i]
                break
        for i,rain in enumerate(rains):
            if rain:
                if rain in rain_records:
                    if zero:
                        ans[zero.pop()] = rain
                        rain_records.remove(rain)
                    else:
                        return []
                else:
                    rain_records.add(rain)
            else:
                ans[i] = t
                zero.append(i)
        return ans

if __name__ == '__main__':
    s = Solution()
    r = s.avoidFlood([69,0,0,0,69])
    print(r)